
#include "Controller.h"

//------------------------------------------------------------------------------
// Name: Controller
//------------------------------------------------------------------------------
Controller::Controller() : data_(0), read_index_(0), connected_(true) {
}

//------------------------------------------------------------------------------
// Name: read
//------------------------------------------------------------------------------
uint8_t Controller::read() {
	if(read_index_++ < 8) {
		return data_.read();
	} else {
		return 0x01;
	}
}

//------------------------------------------------------------------------------
// Name: poll
//------------------------------------------------------------------------------
void Controller::poll() {

	if(connected_) {
        data_.load(static_cast<uint8_t>(keystate_.to_ulong()));
		read_index_ = 0;
	}
}
